<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>CFHibernate Test</title>
</head>

<body>

<cfscript>
user = createObject("java", "java.util.HashMap").init();
addresses = createObject("java", "java.util.HashSet").init();
user.put("id", createObject("java", "java.lang.Integer").init(0));
user.put("firstName", "CF");
user.put("lastName", "Tester");
user.put("email", "kw@aol.com");
address = createObject("java", "java.util.HashMap").init();
address.put("id", createObject("java", "java.lang.Integer").init(0));
address.put("address1", "18 Walter Payton Way");
address.put("city", "Chicago");
address.put("state", "IL");
address.put("zip", "343434");
address.put("$type$", "cfhibernate.model.user.address.address");
addresses.add(address);
user.put("addresses", addresses);
user.put("$type$", "cfhibernate.model.user.user");
</cfscript>

<cfdump var="#user.toString()#" label="user">

<cfset sessionFactory = Application.hibernateConfig.buildSessionFactory()>
<cfset EntityMode = createObject("java", "org.hibernate.EntityMode")>
<cfset mySession = sessionFactory.openSession()>
<cfset tx = 0>
<cfset mySession = mySession.getSession(EntityMode.MAP)>
<cfset tx = mySession.beginTransaction()>

<cfset mySession.saveOrUpdate(user)>
<cfset tx.commit()>
<cfset mySession.close()>
<cfset sessionFactory.close()>

</body>
</html>